package com.tidc.seaserverweb.controller;

import com.aliyuncs.exceptions.ClientException;
import com.tidc.seaservermodel.aspect.WebLog;
import com.tidc.seaservermodel.entity.Fres;
import com.tidc.seaservermodel.entity.User;
import com.tidc.seaservermodel.exception.TidcBadParent;
import com.tidc.seaservermodel.exception.TidcRestException;
import com.tidc.seaservermodel.verify.SecondaryUserVerify;
import com.tidc.seaserverservice.service.UserService;
import org.apache.ibatis.annotations.Param;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotNull;


@RequestMapping("/user")
@RestController
public class UserController {
    @Resource
    private UserService userService;
    @PostMapping("/register")
    public Fres<String> register(@RequestBody @Validated({SecondaryUserVerify.class}) User user) throws TidcBadParent {
        return userService.register(user);
    }
    @GetMapping("/codes")
    public Fres<String> getCode(@Param("type") int type, @Param("phone") String phone, HttpServletRequest req) throws TidcBadParent, TidcRestException, ClientException {
        return userService.getCode(type,phone,req);
    }
}
